/*LICENSE_BEGIN
 * ******************************************************************
 * Copyright 2006 by the Dainamite Robocup-Team at the
 * DAI-Labor, TU-Berlin (www.dai-labor.de)
 * 
 * Members of Dainamite are:
 * Holger Endert
 * Robert Wetzker
 * Thomas Karbe
 * Axel Heßler
 * Philippe Bütter
 * Felix Brossmann
 * 
 * Licensed under the GNU GPL (General Public License) Free Software 
 * License, Version 2. You may use this file only in compliance with 
 * the License. You may obtain a copy of the License at:
 * 
 * http://www.fsf.org/licensing/licenses/gpl.txt
 * ******************************************************************
LICENSE_END*/
package robocup.component.infotypes;

/**
 * This class informs abour messages, which were shouted by other players.
 */
public class PlayerSayInfo extends AuralInfo {

	/**
	 * The relative direction of the hearde message.
	 */
	private double direction;

	/**
	 * The message itself.
	 */
	private String message;

	/**
	 * A flag indicating, that the message was sent by a teammate.
	 */
	private boolean our = false;

	/**
	 * The number of the sender.
	 */
	private int number = -1;

	/**
	 * An info-object holding the heared message of another player
	 * 
	 * @param iCycle -
	 *            the time, when it was heared
	 * @param iDirection -
	 *            from which direction it was heared
	 * @param iMessage -
	 *            the message
	 */
	public PlayerSayInfo(int iCycle, double iDirection, String iMessage) {
		super(iCycle);
		this.direction = iDirection;
		if (iMessage != null) {
			if (iMessage.startsWith("\""))
				iMessage = iMessage.substring(1, iMessage.length() - 1);
		}
		this.message = iMessage;
		this.infoType = Info.TYPE_AURAL_PSI;
	}

	/**
	 * @return Returns the direction.
	 */
	public double getDirection() {
		return this.direction;
	}

	/**
	 * @return Returns the message.
	 */
	public String getMessage() {
		return this.message;
	}

	/**
	 * @return A debug-string for this info-object.
	 */
	@Override
	public String toString() {
		return ("PlayerMessage: " + this.direction + ", " + this.message);
	}

	/**
	 * Sets the direction from where this message was heared.
	 * @param direction - the relative direction.
	 */
	public void setDirection(double direction) {
		this.direction = direction;
	}

	/**
	 * Sets the heared message.
	 * @param message
	 */
	public void setMessage(String message) {
		if (message != null) {
			if (message.startsWith("\""))
				message = message.substring(1, message.length() - 1);
		}
		this.message = message;
	}

	/**
	 * Checks, whether the sender belongs to our team or not.
	 * @return true, if sender is a teammate.
	 */
	public boolean isOur() {
		return this.our;
	}

	/**
	 * Sets the sender of the message to be a teammate or not.
	 * @param our - true if teammate, else opponent.
	 */
	public void setOur(boolean our) {
		this.our = our;
	}
	
	/**
	 * @return Returns the number of the sender.
	 */
	public int getNumber() {
		return this.number;
	}

	/**
	 * Sets the number of the sender.
	 * @param number
	 */
	public void setNumber(int number) {
		this.number = number;
	}
}
